package com.reflection;


import java.lang.reflect.Method;

public class Test {

    public static void main(String[] args) {
//        Person p = new Person();
//        p.eat();
//
//        Student s = new Student();
//        s.eat();
//        s.gotoSchool();
//
        //person 编译时类型， student运行时类型
        Person ps = new Student();

        Class clazz = ps.getClass();
        Method[] mArr = clazz.getMethods();
        for (Method method : mArr) {
            System.out.println(method.getName());
        }
        try {
            Person p = (Person)clazz.newInstance();

            p.eat();
        } catch (Exception e){

        }

    }
}
